# , results="asis"
# create graphing function
function.graph <- function(df){
# create looping variable
description_sel <- unique(dat$description)
# create for loop to produce ggplot2 graphs
for (i in 1:length(description_sel)) {
dat_plot <- dat %>%
filter(description == description_sel[i])
url_sel <- dat2 %>%
filter(description == description_sel[i]) %>%
select(url)
#print(i)
#print(paste0("3333333333333333"))
#print(description_sel[i])
#print(as.character(url_sel))
#print(paste0("<a href='", url_sel, "'>", "link", "</a>"))
p <-ggplot(dat_plot, aes(hour_of_day, values)) +
geom_col(stat = "identity", aes(fill = variable), position = "dodge") +
scale_x_continuous(breaks= dat_plot$hour_of_day) +
labs(title=paste0(description_sel[i], "\n", url_sel) ,
subtitle = "Popularity for any given hour is shown relative to the typical peak popularity for the business for the week",
x ="time",
y = "")+
theme(
plot.title = element_text(size=28, colour = "#0033cc"),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
legend.title=element_blank(),
legend.position='top',
legend.justification='left',
legend.direction="vertical"
)+
scale_fill_manual(values=c("#E6B0AA", "#CCD1D1"))
# print plots to screen
print(p)
}}
# run function.graph
function.graph(dat)